import React from 'react';
import {Form, Input, DatePicker} from 'antd';
import { WeaBrowser,WeaDatePicker  } from 'ecCom';
const FormItem = Form.Item;
import FormGroup from './base/FormGroup';
import FormItem4Title from './base/FormItem4Title';
import FormItem4ShowNum from './base/FormItem4ShowNum';
import FormItem4LinkMode from './base/FormItem4LinkMode';
import FormItem4Field from './base/FormItem4Field';

// 知识订阅
export default class Content_34 extends React.Component {
    constructor(props) {
        super(props);
        this.onChange = this.onChange.bind(this);
        this.ChangeEndDate = this.ChangeEndDate.bind(this);
        this.ChangeStartDate = this.ChangeStartDate.bind(this);
    }
    onChange(ids,names,datas){
        this.props.form.setFieldsValue({'eContentSubscribeDocCatalog': ids});
    }
    ChangeEndDate(value){
        this.props.form.setFieldsValue({'eContentSubscribeEndDate': value});
    }
    ChangeStartDate(value){
        this.props.form.setFieldsValue({'eContentSubscribeStartDate': value});
    }
    render() {
        const {eShareLevel, eContent} = this.props.data;
        const {eSubscribeDocCatalog, eSubscribeDocCatalogIds, eSubscribeTheme, eSubscribeStartDate, eSubscribeEndDate} = eContent;
        const {getFieldProps} = this.props.form;
        const {formItemLayout} = this.props;
        let eFormItem4SubscribeDocCatalog = <div></div>;
        let eFormItem4SubscribeTheme = <div></div>;
        let eFormItem4SubscribeStartDate = <div></div>;
        let eFormItem4SubscribeEndDate = <div></div>;
        if (eShareLevel == '2') {
            getFieldProps('eContentSubscribeDocCatalog', {initialValue: eSubscribeDocCatalogIds || ''});
            eFormItem4SubscribeDocCatalog = (
                <FormItem label="文档目录" {...formItemLayout}>
                    <div style={{display: 'inline-block', width: '410px', margin: '5px', verticalAlign: 'middle'}}>
                        <WeaBrowser
                            type={'doccategory'}
                            isMultCheckbox = {true}
                            isSingle={false}
                            replaceDatas={eSubscribeDocCatalog || []}
                            onChange={this.onChange}
                        />
                    </div>
                </FormItem>
            );
            const eSubscribeThemeProps = getFieldProps('eContentSubscribeTheme', {initialValue: eSubscribeTheme});
            eFormItem4SubscribeTheme = (
                <FormItem label="订阅主题" {...formItemLayout}>
                    <Input size="default" style={{width: '80%'}} {...eSubscribeThemeProps}/>
                </FormItem>
            );
            getFieldProps('eContentSubscribeStartDate', {initialValue: eSubscribeStartDate});
            eFormItem4SubscribeStartDate = (
                <FormItem label="订阅起始日期" {...formItemLayout}>
                    <WeaDatePicker
                      value={eSubscribeStartDate}
                      onChange={this.ChangeStartDate}
                    />
                </FormItem>
            );
            getFieldProps('eContentSubscribeEndDate', {initialValue: eSubscribeEndDate});
            eFormItem4SubscribeEndDate = (
                <FormItem label="订阅最终日期" {...formItemLayout}>
                    <WeaDatePicker
                      value={eSubscribeEndDate}
                      onChange={this.ChangeEndDate}
                    />
                </FormItem>
            );
        }
        return (
            <Form horizontal className="esetting-form">
                <FormGroup title="基本信息">
                    <FormItem4Title {...this.props}/>
                    <FormItem4ShowNum {...this.props}/>
                    <FormItem4LinkMode {...this.props}/>
                    <FormItem4Field {...this.props}/>
                    {eFormItem4SubscribeDocCatalog}
                    {eFormItem4SubscribeTheme}
                    {eFormItem4SubscribeStartDate}
                    {eFormItem4SubscribeEndDate}
                </FormGroup>
            </Form>
        );

    }
}